{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 正确的log输出 60分。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logical and\n",
      "epoch 0 sample 0  [1 2 0 0 0 0 0]\n",
      "epoch 0 sample 1  [1 2 0 1 -1 0 -1]\n",
      "epoch 0 sample 2  [0 2 -1 1 0 -1 -1]\n",
      "epoch 0 sample 3  [0 1 -2 0 1 1 1]\n",
      "epoch 1 sample 0  [1 2 -1 0 0 0 0]\n",
      "epoch 1 sample 1  [1 2 -1 0 0 0 0]\n",
      "epoch 1 sample 2  [1 2 -1 1 0 -1 -1]\n",
      "epoch 1 sample 3  [1 1 -2 0 1 1 1]\n",
      "epoch 2 sample 0  [2 2 -1 0 0 0 0]\n",
      "epoch 2 sample 1  [2 2 -1 1 -1 0 -1]\n",
      "epoch 2 sample 2  [1 2 -2 0 0 0 0]\n",
      "epoch 2 sample 3  [1 2 -2 1 0 0 0]\n",
      "epoch 3 sample 0  [1 2 -2 0 0 0 0]\n",
      "epoch 3 sample 1  [1 2 -2 0 0 0 0]\n",
      "epoch 3 sample 2  [1 2 -2 0 0 0 0]\n",
      "epoch 3 sample 3  [1 2 -2 1 0 0 0]\n",
      "epoch 4 sample 0  [1 2 -2 0 0 0 0]\n",
      "epoch 4 sample 1  [1 2 -2 0 0 0 0]\n",
      "epoch 4 sample 2  [1 2 -2 0 0 0 0]\n",
      "epoch 4 sample 3  [1 2 -2 1 0 0 0]\n",
      "epoch 5 sample 0  [1 2 -2 0 0 0 0]\n",
      "epoch 5 sample 1  [1 2 -2 0 0 0 0]\n",
      "epoch 5 sample 2  [1 2 -2 0 0 0 0]\n",
      "epoch 5 sample 3  [1 2 -2 1 0 0 0]\n",
      "epoch 6 sample 0  [1 2 -2 0 0 0 0]\n",
      "epoch 6 sample 1  [1 2 -2 0 0 0 0]\n",
      "epoch 6 sample 2  [1 2 -2 0 0 0 0]\n",
      "epoch 6 sample 3  [1 2 -2 1 0 0 0]\n",
      "epoch 7 sample 0  [1 2 -2 0 0 0 0]\n",
      "epoch 7 sample 1  [1 2 -2 0 0 0 0]\n",
      "epoch 7 sample 2  [1 2 -2 0 0 0 0]\n",
      "epoch 7 sample 3  [1 2 -2 1 0 0 0]\n",
      "epoch 8 sample 0  [1 2 -2 0 0 0 0]\n",
      "epoch 8 sample 1  [1 2 -2 0 0 0 0]\n",
      "epoch 8 sample 2  [1 2 -2 0 0 0 0]\n",
      "epoch 8 sample 3  [1 2 -2 1 0 0 0]\n",
      "epoch 9 sample 0  [1 2 -2 0 0 0 0]\n",
      "epoch 9 sample 1  [1 2 -2 0 0 0 0]\n",
      "epoch 9 sample 2  [1 2 -2 0 0 0 0]\n",
      "epoch 9 sample 3  [1 2 -2 1 0 0 0]\n",
      "logical or\n",
      "epoch 0 sample 0  [1 2 0 0 0 0 0]\n",
      "epoch 0 sample 1  [1 2 0 1 0 0 0]\n",
      "epoch 0 sample 2  [1 2 0 1 0 0 0]\n",
      "epoch 0 sample 3  [1 2 0 1 0 0 0]\n",
      "epoch 1 sample 0  [1 2 0 0 0 0 0]\n",
      "epoch 1 sample 1  [1 2 0 1 0 0 0]\n",
      "epoch 1 sample 2  [1 2 0 1 0 0 0]\n",
      "epoch 1 sample 3  [1 2 0 1 0 0 0]\n",
      "epoch 2 sample 0  [1 2 0 0 0 0 0]\n",
      "epoch 2 sample 1  [1 2 0 1 0 0 0]\n",
      "epoch 2 sample 2  [1 2 0 1 0 0 0]\n",
      "epoch 2 sample 3  [1 2 0 1 0 0 0]\n",
      "epoch 3 sample 0  [1 2 0 0 0 0 0]\n",
      "epoch 3 sample 1  [1 2 0 1 0 0 0]\n",
      "epoch 3 sample 2  [1 2 0 1 0 0 0]\n",
      "epoch 3 sample 3  [1 2 0 1 0 0 0]\n",
      "epoch 4 sample 0  [1 2 0 0 0 0 0]\n",
      "epoch 4 sample 1  [1 2 0 1 0 0 0]\n",
      "epoch 4 sample 2  [1 2 0 1 0 0 0]\n",
      "epoch 4 sample 3  [1 2 0 1 0 0 0]\n",
      "epoch 5 sample 0  [1 2 0 0 0 0 0]\n",
      "epoch 5 sample 1  [1 2 0 1 0 0 0]\n",
      "epoch 5 sample 2  [1 2 0 1 0 0 0]\n",
      "epoch 5 sample 3  [1 2 0 1 0 0 0]\n",
      "epoch 6 sample 0  [1 2 0 0 0 0 0]\n",
      "epoch 6 sample 1  [1 2 0 1 0 0 0]\n",
      "epoch 6 sample 2  [1 2 0 1 0 0 0]\n",
      "epoch 6 sample 3  [1 2 0 1 0 0 0]\n",
      "epoch 7 sample 0  [1 2 0 0 0 0 0]\n",
      "epoch 7 sample 1  [1 2 0 1 0 0 0]\n",
      "epoch 7 sample 2  [1 2 0 1 0 0 0]\n",
      "epoch 7 sample 3  [1 2 0 1 0 0 0]\n",
      "epoch 8 sample 0  [1 2 0 0 0 0 0]\n",
      "epoch 8 sample 1  [1 2 0 1 0 0 0]\n",
      "epoch 8 sample 2  [1 2 0 1 0 0 0]\n",
      "epoch 8 sample 3  [1 2 0 1 0 0 0]\n",
      "epoch 9 sample 0  [1 2 0 0 0 0 0]\n",
      "epoch 9 sample 1  [1 2 0 1 0 0 0]\n",
      "epoch 9 sample 2  [1 2 0 1 0 0 0]\n",
      "epoch 9 sample 3  [1 2 0 1 0 0 0]\n",
      "logical xor\n",
      "epoch 0 sample 0  [1 2 0 0 0 0 0]\n",
      "epoch 0 sample 1  [1 2 0 1 0 0 0]\n",
      "epoch 0 sample 2  [1 2 0 1 0 0 0]\n",
      "epoch 0 sample 3  [1 2 0 1 -1 -1 -1]\n",
      "epoch 1 sample 0  [0 1 -1 0 0 0 0]\n",
      "epoch 1 sample 1  [0 1 -1 0 1 0 1]\n",
      "epoch 1 sample 2  [1 1 0 1 0 0 0]\n",
      "epoch 1 sample 3  [1 1 0 1 -1 -1 -1]\n",
      "epoch 2 sample 0  [0 0 -1 0 0 0 0]\n",
      "epoch 2 sample 1  [0 0 -1 0 1 0 1]\n",
      "epoch 2 sample 2  [1 0 0 0 0 1 1]\n",
      "epoch 2 sample 3  [1 1 1 1 -1 -1 -1]\n",
      "epoch 3 sample 0  [0 0 0 0 0 0 0]\n",
      "epoch 3 sample 1  [0 0 0 0 1 0 1]\n",
      "epoch 3 sample 2  [1 0 1 1 0 0 0]\n",
      "epoch 3 sample 3  [1 0 1 1 -1 -1 -1]\n",
      "epoch 4 sample 0  [0 -1 0 0 0 0 0]\n",
      "epoch 4 sample 1  [0 -1 0 0 1 0 1]\n",
      "epoch 4 sample 2  [1 -1 1 0 0 1 1]\n",
      "epoch 4 sample 3  [1 0 2 1 -1 -1 -1]\n",
      "epoch 5 sample 0  [0 -1 1 1 0 0 -1]\n",
      "epoch 5 sample 1  [0 -1 0 0 1 0 1]\n",
      "epoch 5 sample 2  [1 -1 1 0 0 1 1]\n",
      "epoch 5 sample 3  [1 0 2 1 -1 -1 -1]\n",
      "epoch 6 sample 0  [0 -1 1 1 0 0 -1]\n",
      "epoch 6 sample 1  [0 -1 0 0 1 0 1]\n",
      "epoch 6 sample 2  [1 -1 1 0 0 1 1]\n",
      "epoch 6 sample 3  [1 0 2 1 -1 -1 -1]\n",
      "epoch 7 sample 0  [0 -1 1 1 0 0 -1]\n",
      "epoch 7 sample 1  [0 -1 0 0 1 0 1]\n",
      "epoch 7 sample 2  [1 -1 1 0 0 1 1]\n",
      "epoch 7 sample 3  [1 0 2 1 -1 -1 -1]\n",
      "epoch 8 sample 0  [0 -1 1 1 0 0 -1]\n",
      "epoch 8 sample 1  [0 -1 0 0 1 0 1]\n",
      "epoch 8 sample 2  [1 -1 1 0 0 1 1]\n",
      "epoch 8 sample 3  [1 0 2 1 -1 -1 -1]\n",
      "epoch 9 sample 0  [0 -1 1 1 0 0 -1]\n",
      "epoch 9 sample 1  [0 -1 0 0 1 0 1]\n",
      "epoch 9 sample 2  [1 -1 1 0 0 1 1]\n",
      "epoch 9 sample 3  [1 0 2 1 -1 -1 -1]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "# 逻辑与数据\n",
    "samples_and = [\n",
    "    [0, 0, 0],\n",
    "    [1, 0, 0],\n",
    "    [0, 1, 0],\n",
    "    [1, 1, 1],\n",
    "]\n",
    "\n",
    "# 逻辑或数据\n",
    "samples_or = [\n",
    "    [0, 0, 0],\n",
    "    [1, 0, 1],\n",
    "    [0, 1, 1],\n",
    "    [1, 1, 1],\n",
    "]\n",
    "\n",
    "#逻辑异或数据\n",
    "samples_xor = [\n",
    "    [0, 0, 0],\n",
    "    [1, 0, 1],\n",
    "    [0, 1, 1],\n",
    "    [1, 1, 0],\n",
    "]\n",
    "\n",
    "\n",
    "\n",
    "def perceptron(samples):\n",
    "    w = np.array([1, 2])\n",
    "    b = 0\n",
    "    a = 1\n",
    "\n",
    "    for i in range(10):\n",
    "        for j in range(4):\n",
    "            x = np.array(samples[j][:2])\n",
    "            y = 1 if np.dot(w, x) + b > 0 else 0\n",
    "            d = np.array(samples[j][2])\n",
    "            \n",
    "            delta_b = a*(d-y)\n",
    "            delta_w = a*(d-y)*x\n",
    "\n",
    "            print('epoch {} sample {}  [{} {} {} {} {} {} {}]'.format(\n",
    "                i, j, w[0], w[1], b, y, delta_w[0], delta_w[1], delta_b\n",
    "            ))\n",
    "            w = w + delta_w\n",
    "            b = b + delta_b\n",
    "\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    print('logical and')\n",
    "    perceptron(samples_and)\n",
    "    print('logical or')\n",
    "    perceptron(samples_or)\n",
    "    print('logical xor')\n",
    "    perceptron(samples_xor)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 解释为什么这样的感知器代码无法完成异或功能 40分。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 方法一：XOR有如下数据表：\n",
    "\n",
    "| 编号 | $$x_1$$ | $$x_2$$ | $$d$$ |\n",
    "| :--: | :-----: | :-----: | :---: |\n",
    "|  1   |    0    |    0    |   0   |\n",
    "|  2   |    1    |    0    |   1   |\n",
    "|  3   |    0    |    1    |   1   |\n",
    "|  4   |    1    |    1    |   0   |\n",
    "\n",
    "### 则w[0],w[1],b必须满足如下方程组:\n",
    "### 1). w[0] + w[1] - b ＜ 0 --> b > w[0] + w[1]\n",
    "### 2). w[0] + 0 - b ≥ 0     --> 0 ≥ b - w[0]\n",
    "### 3). 0 + 0 - b ＜ 0  -->   b > 0\n",
    "### 4). 0 + w[1] - b ≥ 0   --> 0 ≥ b - w[1]\n",
    "### 显然，该方程组是矛盾的，无解！这就说明单层感知器是无法解决异或问题的。\n"
   ]
  },
  {
   "attachments": {
    "image.png": {
     "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaoAAAEbCAYAAACLGcAmAAAgAElEQVR4Ae3dCXQddd3/8W/Wpm3SJumetulC6U6BLkBFoKAUAcFS2QQEBdncQBT0qMfjI4KP4OMBBZQ/4nn+sipF1oIspbYFKZTSxa5Ak+5pm27pkqRZn/P5cSbeLIXeuXMnd3n/zrnn3tzM/GZ+r1m+81vmTkZzc3OzkRBAAAEEEEhQgcwEXS9WCwEEEEAAASdAoGJHQAABBBBIaAECVUJvHlYOAQQQQIBAxT6AAAIIIJDQAgSqhN48rBwCCCCAAIGKfQABBBBAIKEFCFQJvXlYOQQQQAABAhX7AAIIIIBAQgsQqBJ687ByCCCAAAIEKvYBBBBAAIGEFshO1LXTLzsdPHjQMjIy3CtR15P1QgABBBBoL9DU1GTdunWzzMzY60MJG6h2795tEydOtJKSEsvKymqvwDcIIIAAAgkpoIrGli1b7I033rDhw4fHvI4JG6gUhYuLi+2hhx5y7zGXlAwQQAABBEIRqKurs8svvzywSkbCBipp5uTkWP/+/a13796h4LIQBBBAAIHYBRSodP5W100QKfbGwyDWgjwQQAABBBA4jACB6jAwfI0AAgggkBgCBKrE2A6sBQIIIIDAYQQIVIeB4WsEEEAAgcQQIFAlxnZgLRBAAAEEDiNAoDoMDF8jgAACCCSGAIEqMbYDa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VbVFlUnnBtWaNMJVgya0nb3gJS+dpHXe0DQafOPN79XEg1ifzspDx7bOhyqjPquJV2X3XrqQ0blDgVkDTXShp3OIglfkxX5nrH9K9VHp5HPzzTe7q+I77rjDoV911VXuZK2hqepIPvnkk90oNw1D1a8lawdUFV+dq6mS5PDjH//YNVtoZ9MJWG3t6n+Qg/7WFdLdd9/tTky33HKLO3Hrux/84AeuCTCZLVR71En21ltvta9//evuIuX0009398ppWK4uYjTiURc2qZzkoMFCOga0r+tEpHuodIJWk6cuVjRCVhcp+vVwDUueNm2aa1nQfqDgpX0p2ZMctK3PPvtsu/DCC13rgo4HDbB59tlnXRl1XjjttNPcBd6dd97p9hkFrt/85jcp0dKibfjaa6/Z73//e9cvqwt6jez77ne/2xKo5aPbE9SyoKdMaGi+jHR+6OyUcr9MoYNPzX+6alBTnmpLCkZqytHfqtKr5qDalK4ovCYxXYWnQrOXt0OpvGq60dWSyqyDTkllloNM1BQiJ+9kpO909anpkz1pG8tANUudoLV91eSl8nomkbUFTa+ahJpH5ZMq+4LKpVqSHJTUBCYHHSdyUVnloCtt1SJS9ZhQDUJNWN5oR9Wk5CAbJe3z2uaaRidx2eh40P6g/+k8kexJZfXOjdov1Jet8qmsSjpGdC7wDNQKpRYonRMij5XOcEi5QNUZiCwTAQQQQCB+AinVRxU/JnJGAAEEEOgsAQJVZ8mzXAQQQACBIxIgUB0RExMhgAACCHSWAIGqs+RZLgIIIIDAEQkQqI6IiYkQQAABBDpLICEDlYbJavgkCQEEohfo7OOns5cfvRhzJLpAwgWqZH4eVqJvbNYv9QU6+/jp7OWn/hZOzxIm3G3n+rkO3XSYjM/DSs9diFInkkBnHz+dvfxE2hasS3AC3PAbnCU5IYAAAgjEQSDhmv7iUEayRAABBBBIYgECVRJvPFYdAQQQSAcBAlU6bGXKiAACCCSxAIEqiTceq44AAgikg8D/AbjR4MO77tSXAAAAAElFTkSuQmCC"
    }
   },
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 方法二： 在二维平面上画出图形\n",
    "![image.png](attachment:image.png)\n",
    "### 显然，对于异或，负实例样本集[(0, 0), (1, 1)] 和 正实例样本集[(0, 1), (1, 0)]是二维中是不能被线性分割的。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
